import Mock from 'mockjs'

const data = Mock.mock({
	'list|5': [{
		name: '@cname',
		age: '@integer(18,30)',
		id: '@id'
	}]
})


Mock.mock('/api/list', () => {
	return {
		code: 200,
		data: data.list
	}
})

Mock.mock('/api/detail', 'post', (req) => {
	const { id } = JSON.parse(req.body);
	const item = data.list.find(v => v.id === id)
	return {
		code: 200,
		data: item
	}
})